package com.example.factory;

import com.example.entity.DayHourChargeConfig;
import com.example.strategy.ParkingFeeStrategy;

import java.math.BigDecimal;
import java.util.function.Function;

public class ParkingFeeStrategyFactory {


    public static ParkingFeeStrategy createStrategy(DayHourChargeConfig config) {
        return config.getHalfHourRate() != null ?
                ParkingFeeStrategy.halfHourStrategy() :
                ParkingFeeStrategy.hourlyStrategy();
    }

    public static Function<BigDecimal, BigDecimal> createFeeAdjuster(String type, DayHourChargeConfig config) {
        switch (type) {
            case "MAX_FEE": return ParkingFeeStrategy.maxFeeStrategy(config);
            case "OVERNIGHT": return fee -> fee; // 实际实现中替换为过夜费策略
            default: return fee -> fee;
        }
    }

}
